﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Ext.h".
//-------------------------------------------------------------------

#ifndef _UXS_AL_SOUND_EFFECTS_H
#define _UXS_AL_SOUND_EFFECTS_H

#pragma once

#include "ALCommon.h"

namespace UX_STL
{
namespace ALShell
{

	//
	// Sound Filter
	//

	class UX_EXPORT ALSoundFilter : public ALBaseObject
	{
	protected:
		ALuint			_uID;
		al_filter::type	_eType;
		
	private:
		virtual void _Release()		{ delete this; }

	public:
		ALSoundFilter();
		virtual ~ALSoundFilter();

		bool Create(al_filter::type eType);
		void Destroy();

		ALuint			Id()			const	{ return _uID; }
		al_filter::type	FilterType()	const	{ return _eType; }
	};

	SHARED_POINTER( ALSoundFilter );



	//
	// Sound Effect
	//

	class UX_EXPORT ALSoundEffect : public ALBaseObject
	{
	protected:
		ALuint			_uID;
		al_effect::type	_eType;
		
	private:
		virtual void _Release()		{ delete this; }

	public:
		ALSoundEffect();
		virtual ~ALSoundEffect();

		bool Create(al_effect::type eType);
		void Destroy();
		
		ALuint			Id()			const	{ return _uID; }
		al_effect::type	EffectType()	const	{ return _eType; }
	};
	
	SHARED_POINTER( ALSoundEffect );



	//
	// Sound Effect AUX Slot
	//

	class UX_EXPORT ALSoundEffectSlot : public ALBaseObject
	{
	protected:
		ALSoundEffectPtr	_pEffect;
		ALuint				_uID;
		
	private:
		virtual void _Release()		{ delete this; }

	public:
		ALSoundEffectSlot();
		virtual ~ALSoundEffectSlot();

		bool Create();
		void Destroy();

		void SetEffect(const ALSoundEffectPtr &pEf);
		void SetVolume(float fValue);
		
		ALuint					Id()		const	{ return _uID; }
		const ALSoundEffectPtr&	Effect()	const	{ return _pEffect; }
	};

	SHARED_POINTER( ALSoundEffectSlot );




//---------------------- ALSoundEffectSlot ------------------------//

	inline void ALSoundEffectSlot::SetEffect(const ALSoundEffectPtr &pEf)
	{
		_pEffect = pEf;
		AL_CALL( alAuxiliaryEffectSloti( _uID, AL_EFFECTSLOT_EFFECT,
							_pEffect != null ? _pEffect->Id() : 0 ) );
	}

	inline void ALSoundEffectSlot::SetVolume(float fValue)
	{
		AL_CALL( alAuxiliaryEffectSlotf( _uID, AL_EFFECTSLOT_GAIN, fValue ) );
	}

//-------------------------------------------------------------------

}	// ALShell
}	// UX_STL

#endif	// _UXS_AL_SOUND_EFFECTS_H